<template>
<d2-container>
  <el-card class="order-list" shadow="never">
    <el-table v-loading="tableLoading" :data="tableData" stripe>
      <el-table-column type="index" label="编号" width="50" />
       <el-table-column prop="username" label="昵称" />
        <el-table-column prop="headimgurl" label="头像">
        <template slot-scope="{ row }">
          <el-image
            v-if="row.headimgurl"
            style="width: 50px; height: 50px"
            :src="row.headimgurl"
            :preview-src-list="[row.headimgurl]"
          />
          <span v-else>暂无图片</span>
        </template>
      </el-table-column>
       <el-table-column prop="cut_money" label="金额" />
       <el-table-column prop="goods_now_money" label="当前剩余价格" />
       <el-table-column prop="dateline" label="添加时间" />
    </el-table>
    <el-pagination :total="pagination.total" :page-size="pagination.pageSize" @current-change="changeHandler" />
  </el-card>
  </d2-container>
</template>

<script>
import { crudOptions } from './crud' // 上文的crudOptions配置
import { d2CrudPlus } from '@/components/d2-crud-plus'
import { helpRecord, addObj } from '@/api/winner' // 查询添加修改删除的http请求接口
// import { resetPassword } from '@/api/user'
export default {
  name: 'page1',
  mixins: [d2CrudPlus.crud],
  data () {
    return {
      queryData: {
        id: ''
      },
      tableData: [],
      pagination: {
        currentPage: 1,
        pageSize: 10,
        total: 0
      },
      tableLoading: false,
      submitLoading: false,
      dialogFormVisible: false
    }
  }, // 最核心部分，继承d2CrudPlus.crud
  created () {
    this.initColumns()
  },
  methods: {
    getCrudOptions () {
      return crudOptions
    },
    doRefresh () {
      if (this.$route.query.id) {
        this.queryData.id = this.$route.query.id
      }
      this._getTableData()
    }, // 数据请求
    _getTableData () {
      const { pagination, queryData } = this
      const { id } = queryData
      this.tableLoading = true
      helpRecord(pagination.currentPage, id).then(res => {
        const { list = [], pagination } = res || {}
        this.tableData = list
        // this.tableData.push(_data)
        pagination && (this.pagination = pagination)
      }).finally(() => {
        this.tableLoading = false
      })
    },
    changeHandler (current) {
      this.pagination.currentPage = current
      this._getTableData()
    }
  }
}
</script>
<style>
.el-pagination {
    white-space: nowrap;
    padding: 15px 5px;
    color: #303133;
    font-weight: 700;
}
</style>
